// pages/myMoney/myMoney.js

var app = getApp();
var page=1;
var selectedNews = false;
var newsList = [];

Page({
  data: {
    nocard: false,  
    allMoney: "",
    canMoney: ""  
  },
  //提现历史
  showWithdrawList:function(e){
    wx.navigateTo({
      url: '/pages/withdrawList/withdrawList',
    })
  },
  //提现
  showWithdraw: function (e) {
    wx.navigateTo({
      url: '/pages/withdraw/withdraw?allMoney=' + this.data.canMoney,
    })
  },
  //商品佣金
  showGoodsCommission: function (e) {
    wx.navigateTo({
      url: '/pages/goodsCommission/goodsCommission',
    })
  },
  //名片佣金
  showCommissionFlow: function (e) {
    wx.navigateTo({
      url: '/pages/commissionFlow/commissionFlow',
    })
  },
  //账单明细
  showMenuList: function (e) {
    wx.navigateTo({
      url: '/pages/menuList/menuList',
    })
  },
  showAgentList:function(){
    wx.navigateTo({
      url: '/shopPages/agent_log/agent_log',
    })
  },
  //银行卡
  showCardList: function (e) {
    if (this.data.nocard == true) {
      wx.navigateTo({
        url: '/pages/bankCard/bankCard'
      })
    } else {
      wx.navigateTo({
        url: '/pages/myBankCard/myBankCard?backtype=money'
      })
    }
  },
  onLoad:function(options){
    // 页面初始化 options为页面跳转所带来的参数
  },
  //获取可提现余额
  getAllMoney:function(){
    var that = this;
    var url2 = '/wallet_api/totalCash';
    var params2 = {
      uid: app.globalData.userInfo.id
    };
    app.HttpPostSend(url2, params2, function (res) {
      if (res.msg != "success") {
        app.showTipMsg(res.msg);
      } else {
        that.setData({
          allMoney: res.data.total_cash,
          canMoney: res.data.allow_cash
        })
      }
    });
  },
  onReady:function(){
    // 页面渲染完成
  },
  onShow:function(){
    // 页面显示
    var that = this;
    that.getAllMoney();
    // var url = '/wallet_api/bankList';
    // var params = {
    //   uid: app.globalData.userInfo.id
    // };
    // app.HttpPostSend(url, params, function (res) {
    //   if (res.msg != "success") {
    //     app.showTipMsg(res.msg);
    //   } else {
    //     var cardlist = res.data;
    //     if (res.data) {
    //       if (cardlist.length > 0) {
    //         that.setData({
    //           nocard: false
    //         })
    //       } else {
    //         that.setData({
    //           nocard: true
    //         })
    //       }
    //     } else {
    //       that.setData({
    //         nocard: true
    //       })
    //     }
    //   }
    // });   
  },
  onHide:function(){
    // 页面隐藏
  },
  onUnload:function(){
    // 页面关闭
  },
  // onShareAppMessage: function () {
    
  // },
  /** 
   * 页面上拉触底事件的处理函数 
   */
  onReachBottom: function () {
    
  }
})